package net.quanter.demo.junit5.springboot.controller;

import net.quanter.demo.junit5.springboot.vo.Result;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.IntStream;

/***
 * java9新特性测试
 * @(#) 2020-09-12
 * @author 王老实
 *
 */
@RestController
public class Java9Controller {

    @PostMapping("/list")
    public List<String> list() {
        return List.of("AA", "BB");
    }


    @PostMapping("/iterate")
    public int iterate() {
        return IntStream.iterate(3, x -> x < 10, x -> x+ 3).sum();
    }

    @PostMapping("/optional")
    public Result optional(@RequestBody String hello) {
        return new Result().setValue(hello);
    }
}
